home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / tvalt.exe / TESTGFX.CPP < prev    next >
C/C++ Source or Header  |  1992-10-05  |  1KB  |  65 lines

  1. #define Uses_TApplication
  2. #define Uses_TMenuBar
  3. #define Uses_TSubMenu
  4. #define Uses_TMenuItem
  5. #define Uses_TKeys
  6. #define Uses_TScreen
  7. #define Uses_TMouse
  8. #include <tv.h>
  9.  
  10. #include <graphics.h>
  11.  
  12. extern Boolean useAltWriteMethod;
  13. // This definition is included to show what it looks like; since
  14. // useAltWriteMethod is True by default in NEWWRITE.OBJ, it is not
  15. // necessary.
  16.  
  17. class TMyApp : public TApplication
  18.     {
  19.     public:
  20.         TMyApp();
  21.  
  22.         static TMenuBar *initMenuBar( TRect r );
  23.     };
  24.  
  25. TMyApp::TMyApp() :
  26.         TProgInit( &TMyApp::initStatusLine, &TMyApp::initMenuBar,
  27.                 &TMyApp::initDeskTop )
  28.     {
  29.     }
  30.  
  31. TMenuBar *TMyApp::initMenuBar( TRect r )
  32.     {
  33.     r.b.y = r.a.y+1;
  34.     return new TMenuBar( r,
  35.         *new TSubMenu( "~F~ile", 0 )+
  36.             *new TMenuItem( "E~x~it", cmQuit, kbAltX, hcNoContext, 0 )
  37.         );
  38.     }
  39.  
  40. int main()
  41.     {
  42.     int gdriver = EGA;
  43.     int gmode = EGAHI;
  44.  
  45.     initgraph( &gdriver, &gmode, "\\borlandc\\bgi" );
  46.     if( graphresult() != grOk )
  47.         return 2;
  48.     // This example uses the EGA 640x350x16 graphics mode.
  49.  
  50.     useAltWriteMethod = True;
  51.     // This is the default, so not actually necessary.
  52.  
  53.     TScreen::screenHeight = getmaxy() >> 3;
  54.     TMouse::setRange( TScreen::screenWidth-1, TScreen::screenHeight );
  55.     TMouse::show();
  56.     // Need to adjust the screen height and mouse range so that they
  57.     //    both fill the screen. Need to re-show() the mouse because
  58.     //    setting the graphics mode hid it.
  59.  
  60.     TMyApp app;
  61.     app.run();
  62.     closegraph();
  63.     return 0;
  64.     }
  65.